from rest_framework import serializers
from apps.app01.models import Order, Product, ProductCount, Config, User


class ProductItemSerializer(serializers.Serializer):
    productId = serializers.IntegerField()
    name = serializers.CharField(max_length=255)
    price = serializers.IntegerField()
    count = serializers.IntegerField()
    # config 里存储了配置项的 name 和 choice
    config = serializers.ListField(child=serializers.DictField(), required=False)

class OrderCreateSerializer(serializers.Serializer):
    addressId = serializers.IntegerField()
    totalPrice = serializers.IntegerField()
    products = serializers.ListField(child=ProductItemSerializer())